import { request } from '@/utils/request'
import qs from 'querystring'
const prefix = '/admin'

interface loginParams {
	username: string;
	password: string
}
/**
 * 登录
 * @param body 
 * @returns 
 */
export const loginRequest = (body: loginParams) => {
	return request.post(`${prefix}/login`, body)
}

interface adminParams {
	username: string
	password: string
	phone: string
	building: string
}
/**
 * 添加管理员
 * @param params 
 * @returns 
 */
export const addAdminRequest = (params: adminParams) => {
	return request.post(`${prefix}/addAdmin`, params)
}

/**
 * 修改管理员
 * @param params 
 * @returns 
 */
export const reviseAdminRequest = (params: adminParams) => {
	return request.put(`${prefix}/reviseAdmin`, params)
}

/**
 * 获取管理员
 * @returns 
 */
export const getAdminRequest = () => {
	return request.get(`${prefix}/getAdmin`)
}

/**
 * 查询各楼栋的收入
 * @returns 
 */
export const getAllCostRequest = () => {
	return request.get(`${prefix}/getAllCost`)
}

/**
 * 查询各楼栋的车位类型占用量
 * @param params 
 * @returns 
 */
export const getAllParkingTypeRequest = (params: { building: string }) => {
	return request.get(`${prefix}/getAllParkingType?${qs.stringify(params)}`)
}